<?php
/**
 * @author guoxiaoyong
 * 短信接口
 */
namespace bc\util;

class Sms
{
	private $account = 'sdk_qbaxx';
	private $password = '872932';
	private $sign = '【芝士妈妈在线】';
	private $url = 'http://www.jianzhou.sh.cn/JianzhouSMSWSServer/http/sendBatchMessage';
	
	private $mobile;
	private $text;
	
	
	/**
	 * @return string $text
	 */
	public function getText()
	{
		return $this->text;
	}

	/**
	 * @param string $text
	 */
	public function setText($text)
	{
		$this->text = $text;
	}

	/**
	 * @return the $mobile
	 */
	public function getMobile()
	{
		return $this->mobile;
	}

	/**
	 * @param field_type $mobile
	 */
	public function setMobile($mobile)
	{
		$this->mobile = $mobile;
	}

	public function send()
	{
		if(!$this->getMobile())
		{
			throw new \Exception('mobile can not empty!');
		}
		
		if(!$this->getText())
		{
			throw new \Exception('text can not empty!');
		}
		
		$data = array(
			'account' => $this->account,
			'password' => $this->password,
			'destmobile' => $this->getMobile(),
			'msgText' => $this->getText() . $this->sign,
			'sendDateTime' => date('YmdHis')
		);
		
		$data = http_build_query($data);
		
		$result = Util::httpPost($this->url, $data);
		return $result;
	}
}

